From 9fa654b24307a24b9fa87f993ef742b6de3f5c8c Mon Sep 17 00:00:00 2001 From: robertl Date: Thu, 24 Aug 2006 17:49:03 +0000 Subject: [PATCH] Tweak time handling in KML writer. --- kml.c | 44 ++++++++++++++++---------------------------- vecs.c | 2 +- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/kml.c b/kml.c index 718c4b6a5..26a8269b1 100644 --- a/kml.c +++ b/kml.c @@ -366,14 +366,11 @@ static void kml_output_timestamp(const waypoint *waypointp) { char time_string[64]; if (waypointp->creation_time) { - kml_write_xml(1, "\n"); - xml_fill_in_time(time_string, waypointp->creation_time, XML_LONG_TIME); - if (time_string[0]) { - kml_write_xml(0, "%s\n", - time_string); - } - - kml_write_xml(-1,"\n"); + xml_fill_in_time(time_string, waypointp->creation_time, XML_LONG_TIME); + if (time_string[0]) { + kml_write_xml(0, "%s\n", + time_string); + } } } @@ -383,8 +380,6 @@ static void kml_output_timestamp(const waypoint *waypointp) static void kml_output_trkdescription(computed_trkdata *td) { - char stbuf[100]; - char endbuf[100]; char *max_alt_units; double max_alt; char *min_alt_units; @@ -400,24 +395,22 @@ void kml_output_trkdescription(computed_trkdata *td) min_alt = fmt_distance(td->min_alt, &min_alt_units); distance = fmt_distance(td->distance_meters, &distance_units); - strftime(stbuf, sizeof(stbuf), "%c", localtime(&td->start)); - strftime(endbuf, sizeof(endbuf), "%c", localtime(&td->end)); - /* We won't always have times. Garmin saved tracks, for example... */ - if (td->start) { - kml_write_xml(0, "From %s\n", stbuf); + if (td->start && td->end) { + char time_string[64]; + kml_write_xml(1, "\n"); + xml_fill_in_time(time_string, td->start, XML_LONG_TIME); + kml_write_xml(0, "%s\n", time_string); + xml_fill_in_time(time_string, td->end, XML_LONG_TIME); + kml_write_xml(0, "%s\n", time_string); + kml_write_xml(-1, "\n"); } else { - kml_write_xml(0, "\n", stbuf); + kml_write_xml(0, "\n"); } kml_write_xml(1, "\n"); kml_write_xml(1, "\n"); - if (td->start) { - TD("Start %s", stbuf); - } - if (td->end) { - TD("End %s", endbuf); - } + TD2("Distance %.1f %s", distance, distance_units); if (min_alt != unknown_alt) { TD2("Min Alt %.1f %s", min_alt, min_alt_units); @@ -486,12 +479,7 @@ static void kml_output_description(const waypoint *pt) kml_write_xml(1,"\n"); - if (pt->creation_time) { - char stbuf[100]; - strftime(stbuf, sizeof(stbuf), "%c", - localtime(&pt->creation_time)); - TD("Time: %s", stbuf); - } + TD("Longitude: %f", pt->longitude); TD("Latitude: %f", pt->latitude); if (pt->altitude != unknown_alt) TD2("Altitude: %.1f %s", alt, alt_units); diff --git a/vecs.c b/vecs.c index fd96d6f4f..81ef27ac1 100644 --- a/vecs.c +++ b/vecs.c @@ -410,7 +410,7 @@ vecs_t vec_list[] = { { &kml_vecs, "kml", - "Keyhole Markup Language", + "Google Earth (Keyhole) Markup Language", "kml" }, { -- 2.30.2